package vip.zcn.webmanagement.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import vip.zcn.webmanagement.pojo.Emp;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {

    @Select("SELECT COUNT(*) FROM emp")
    Long count();

    @Select("SELECT * FROM emp LIMIT #{start}, #{pageSize}")
    List<Emp> list1(Integer start, Integer pageSize);

    // @Select("SELECT * FROM emp")
    List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end);

    void delete(List<Integer> ids);


    //新增员工
    @Insert("insert into emp (username, name, gender, image, job, entrydate, dept_id, create_time, update_time) " +
            "values (#{username}, #{name}, #{gender}, #{image}, #{job}, #{entrydate}, #{deptId}, #{createTime}, #{updateTime});")
    void insert(Emp emp);

    @Select("SELECT * FROM emp WHERE id = #{id}")
    Emp selectById(Integer id);

    void update(Emp emp);

    @Select("SELECT * FROM emp WHERE username = #{username} AND password = #{password}")
    Emp getEmpByUsernameAndPassword(Emp emp);
}